<template>
	<view class="pyg_index">
		<!-- 首页搜索框开始 -->
		<SearchInput />
		<!-- 首页搜索框结束 -->
		<!-- 首页轮播图开始 -->
		<view class="pyg_swiper">
			<swiper indicator-color="true" circular="true" indicator-dots="true">
				<swiper-item v-for="(item,index) in swiper_list" :key="item.goods_id">
					<navigator :url="item.navigator_url" :open-type="item.open_type">
						<image :src="item.image_src" mode="widthFix"></image>
					</navigator>
				</swiper-item>
			</swiper>
		</view>
		<!-- 首页轮播图结束 -->
		<!-- 分类导航开始 -->
		<view class="pyg_catitems">
			<block v-for="(item,index) in catItems" :key="item.image_src">
				<navigator :url="item.navigator_url" :open-type="item.open_type">
					<image :src="item.image_src" mode="widthFix"></image>
				</navigator>
			</block>
		</view>
		<!-- 分类导航结束 -->
		<!-- 首页楼层开始 -->
		<view class="pyg_floorData">
			<block v-for="(item,index) in floorData" :key="index">
				<!-- title 开始 -->
				<view class="floor_title">
					<image :src="item.floor_title.image_src" mode="widthFix"></image>
				</view>
				<!-- title 结束 -->
				<!-- product_list 开始 -->
				<view class="product_list">
					<block v-for="(v,i) in item.product_list" :key="v.navigator_url">
						<navigator :url="v.navigator_url" :open-type="v.open_type">
							<image :src="v.image_src"></image>
						</navigator>
					</block>
				</view>
				<!-- product_list 结束 -->
			</block>
		</view>

		<!-- 首页楼层结束 -->
	</view>
</template>

<script>
	import SearchInput from "../../components/search-input.vue"

	export default {
		components: {
			SearchInput
		},
		created: function() {
			this.getSwiperList();
			this.getCatItems();
			this.getFloorData();
		},
		data() {
			return {
				swiper_list: [],
				catItems: [],
				floorData: []
			}
		},
		onLoad() {

		},
		methods: {
			// 实现首页轮播图
			//1. 要来拿到轮播图数据
			//2. 配合使用一下  async await 
			getSwiperList: async function(e) {

				const swiper_list = await this.$request({
					url: "/home/swiperdata"
				});
				this.swiper_list = swiper_list;

			},
			//获取分类导航数据
			getCatItems: async function(e) {
				const catItems = await this.$request({
					url: "/home/catitems"
				});
				this.catItems = catItems;
			},
			// 获取楼层数据
			getFloorData: async function(e) {
				const floorData = await this.$request({
					url: "/home/floordata"
				});
				this.floorData = floorData;
			},
		}
	}
</script>

<style scoped>
	.pyg_index .pyg_swiper swiper {
		height: 340rpx;
	}

	.pyg_index .pyg_swiper swiper swiper-item navigator image {
		height: 100%;
	}

	.pyg_index .pyg_catitems {
		margin-top: 12rpx;
		margin-bottom: 43rpx;
		display: flex;
	}

	.pyg_index .pyg_catitems navigator {
		flex: 1;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.pyg_index .pyg_catitems navigator image {
		height: 140rpx;
		width: 128rpx;
	}

	.pyg_index .pyg_floorData .floor_title {
		margin-top: 10rpx;
	}

	.pyg_index .pyg_floorData .floor_title image {
		height: 59rpx;
	}

	.pyg_index .pyg_floorData .product_list {
		overflow: hidden;
	}

	.pyg_index .pyg_floorData .product_list navigator {
		float: left;
	}

	.pyg_index .pyg_floorData .product_list navigator:nth-child(1) {
		margin-left: 16rpx;
		height: 386rpx;
		width: 232rpx;
	}

	.pyg_index .pyg_floorData .product_list navigator:nth-child(2),
	.pyg_index .pyg_floorData .product_list navigator:nth-child(4) {
		margin-left: 15rpx;
		height: 188rpx;
		width: 233rpx;
	}

	.pyg_index .pyg_floorData .product_list navigator:nth-child(3),
	.pyg_index .pyg_floorData .product_list navigator:nth-child(5) {
		margin-left: 15rpx;
		height: 188rpx;
		width: 223rpx;
	}

	.pyg_index .pyg_floorData .product_list navigator:nth-child(3),
	.pyg_index .pyg_floorData .product_list navigator:nth-child(2) {
		margin-bottom: 10rpx;
	}

	.pyg_index .pyg_floorData .product_list navigator image {
		width: 100%;
		height: 100%;
	}
</style>
